import Mock from "mockjs";

import { Menu } from "../../types/utils.interface";

const users = {
  admin: {
    roles: ["admin"],
    introduction: "I am a super administrator",
    avatar:
      "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
    name: "Super Admin",
  },
  editor: {
    roles: ["editor"],
    introduction: "I am an editor",
    avatar:
      "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
    name: "Normal Editor",
  },
};

const tokens: any = {
  admin: {
    token: "admin",
  },
  editor: {
    token: "editor",
  },
};

Mock.mock("http://localhost:9999/login", "post", (body: any) => {
  const data = JSON.parse(body.body);
  console.log(data.username);
  const token = tokens[data.username];
  if (!token) {
    return {
      message: "失败",
    };
  }
  console.log(data.username);

  return {
    token: token,
  };
});
